<template>
  <div class="approval">
    <el-card class="box-card" style="margin-bottom: 10px;">
      <div style="padding: 5px; box-sizing: border;" 
      v-bind:class="[propB.isActive5? 'bg1': '']"
      @click="changeFn('5')"
      class="risk-model">
        <div class="head-title2">
          <div class="head-title">
            <div class="title">{{$t('approvalDetail.riskModelSuggest')}}</div>
            <div class="info">
              <span>{{$t('approvalDetail.advisePass')}}:</span>
              <span>{{riskModelData.adviceRate}}</span>
            </div>
          </div>
          <div class="info">
            <el-button
              type="primary"
              size="small"
              @click.stop="addDescFn"
              style="background: #6083f7; border-color: #6083f7;"
            >{{$t('approvalDetail.seeDesc')}}</el-button>
          </div>
        </div>
        <div class="detail-info">
          <div class="detail-info-item">
            <span style="width: 30px;" >{{$t('approvalDetail.grade')}}:</span>
            <span>{{riskModelData.level}}</span>
          </div>
          <div class="detail-info-item">
            <span style="width: 100px;">{{$t('approvalDetail.advisePass')}}:</span>
            <span>{{riskModelData.adviceRate}}</span>
          </div>
          <div class="detail-info-item">
            <span style="width: 100px;">{{$t('approvalDetail.MachineRefuseReason')}}:</span>
            <span>{{riskModelData.refuseReson}}</span>
          </div>
          <div class="detail-info-item">
            <span style="width: 100px;">{{$t('approvalDetail.AdzIdAuth')}}:</span>
            <span>{{riskModelData.advenceIdAuth}}</span>
          </div>
          <div class="detail-info-item">
            <span style="width: 100px;">{{$t('approvalDetail.izLenTime')}}:</span>
            <span>{{riskModelData.izTimeSpentOnline}}</span>
          </div>
          <div class="detail-info-item">
            <span style="width: 120px;">{{$t('approvalDetail.izMobileIdAuth')}}:</span>
            <span>{{riskModelData.izPhoneAuth}}</span>
          </div>
        </div>
      </div>
    </el-card>
    <el-dialog :title="$t('approvalDetail.riskModelSuggestDesc')" :visible.sync="dialogDescForm">
      <el-form
        :model="descForm"
        ref="descForm"
        label-width="100px"
        style="width: 90%;"
      >
        <el-form-item :label="$t('grouping.remark')">
          <el-input
            type="textarea"
            size="small"
            v-model="descForm.remark"
            :placeholder="$t('rule.toLength')"
            :maxlength="500"
            disabled=""
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          @click="descFormSave"
        >{{$t('btn.complete')}}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getModalAdvice, getApprovalRemark } from "api/trust/firstApprDetails/index";
export default {
  props: ['propB'],
  data() {
    return {
      listObj: {},
      riskModelData: {
        level: '',
        adviceRate: '',
        refuseReson: '',
        advenceIdAuth: '',
        izTimeSpentOnline: '',
        izPhoneAuth: '',
      },
      lanStatus: null,
      dialogDescForm: false,
      descForm: {
        remark: ""
      },
    };
  },
  computed: {
    ...mapGetters(["elements", "language", "endApprDetails"])
  },
  created() {
    this.getParamsDetail();
    if (this.language === "zh") {
      this.lanStatus = 1;
    } else if (this.language === "en") {
      this.lanStatus = 2;
    } else {
      this.lanStatus = 3;
    }
    //客户风控模型建议
    let riskModelObj = {};
    riskModelObj.orderId = this.listObj.orderId;
    getModalAdvice(riskModelObj).then(res => {
      if (res.status === 200) {
        this.riskModelData = res.data;
        this.$store.dispatch("saveEndPhone", res.data.izPhoneAuth)
      } else {
        this.$message({
          showClose: true,
          type: "warning",
          message: res.message
        });
      }
    });
    // Adv身份认证
    // let orderIdObj = {};
    // orderIdObj.orderId = this.listObj.orderId;
    // identityCheckResultizidata(orderIdObj).then(res => {
    //   if (res.status === 200) {
    //     this.AdzIdAuthData = res.data;
    //   } else {
    //     this.$message({
    //       showClose: true,
    //       type: "warning",
    //       message: res.message
    //     });
    //   }
    // });
    // 在网时长
    // phoneAgeCheckResultizidata(orderIdObj).then(res => {
    //   if (res.status === 200) {
    //     this.izLenTimeData = res.data;
    //   } else {
    //     this.$message({
    //       showClose: true,
    //       type: "warning",
    //       message: res.message
    //     });
    //   }
    // });
    // 手机实名认证
    // teltIdCheckResult(orderIdObj).then(res => {
    //   if (res.status === 200) {
    //     this.izMobileIdAuthData = res.data;
    //   } else {
    //     this.$message({
    //       showClose: true,
    //       type: "warning",
    //       message: res.message
    //     });
    //   }
    // });
    // 机审拒绝原因
    // getRejectCodeByOrderId(orderIdObj).then(res => {
    //   if (res.status === 200) {
    //     switch (res.data) {
    //       case 'AGE':
    //         res.data = this.$t('RiskManager.age');
    //         break;
    //       case 'APPLYTIME':
    //         res.data = this.$t('approval.time');
    //         break;
    //       case 'CONTRACTS':
    //         res.data = this.$t('approvalDetail.contracts');
    //         break;
    //       case 'SYSTEMBLACKLIST':
    //         res.data = this.$t('approvalDetail.systemBlackList');
    //         break;
    //       case 'ADDRESSBOOK':
    //         res.data = this.$t('approvalDetail.addressBook');
    //         break;
    //       case 'IDENTITY':
    //         res.data = this.$t('approvalDetail.IDEntity');
    //         break;
    //       case 'PHONEAGE':
    //         res.data = this.$t('approvalDetail.phoneage');
    //         break;
    //       case 'TELEID':
    //         res.data = this.$t('approvalDetail.teleID');
    //         break;
    //       case 'ADVANCEBLACKLIST':
    //         res.data = this.$t('approvalDetail.advBlackList');
    //         break;
    //       case 'IDNO':
    //         res.data = this.$t('approvalDetail.IDno');
    //         break;
    //       case 'IMEINO':
    //         res.data = this.$t('approvalDetail.IMEINo');
    //         break;
    //       case 'BANKNO':
    //         res.data = this.$t('approvalDetail.bankNo');
    //         break;
    //       case 'PHONENO':
    //         res.data = this.$t('approvalDetail.IDphoneNo');
    //         break;
    //       case 'BILLROLE':
    //         res.data = this.$t('approvalDetail.billRole');
    //         break;
    //       case 'ORGANIC':
    //         res.data = this.$t('approvalDetail.NaturalFlow');
    //         break;
    //     }
    //     this.refuseReason = res.data;
    //   } else {
    //     this.$message({
    //       showClose: true,
    //       type: "warning",
    //       message: res.message
    //     });
    //   }
    // });
  },
  methods: {
    getParamsDetail() {
      this.listObj = this.endApprDetails;
    },
    changeFn(module) {
      this.$emit('change-module', module) // 用来触发父组件定义的@change-type
    },
    // 添加备注
    addDescFn() {
      let obj = {};
      obj.orderId = this.listObj.orderId;
      obj.type = '2';
      getApprovalRemark(obj)
      .then(res => {
        if (res.status === 200) {
          this.dialogDescForm = true;
          this.descForm.remark = res.data;
        }
      })
    },
    // 添加备注保存
    descFormSave() {
      this.dialogDescForm = false;
      this.$emit('click-complete', '5')
    },
  }
};
</script>

<style scoped lang="scss">
input::-webkit-input-placeholder {
  font-size: 12px;
}
.approval-detail {
  width: 100%;
  height: 100%;
  padding-top: 10px;
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
  position: relative;
}
.title {
  line-height: 22px;
  font-size: 16px;
  display: flex;
  align-items: center;
  font-weight: bold;
}
.title:before {
  display: block;
  content: "";
  width: 3px;
  height: 16px;
  background-color: #309afe;
}
.title:before {
  margin-right: 8px;
}
::before {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}
.detail-info {
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  margin-left: 12px;
  margin-top: 5px;
  .detail-info-item {
    width: 33%;
    line-height: 30px;
    display: flex;
    padding-right: 20px;
    box-sizing: border-box;
    span:nth-child(1) {
      display: inline-block;
      width: 80px;
      text-align: left;
      margin-right: 5px;
      color: #616264;
    }
    span:nth-child(2) {
      color: #8a8a8c;
      display: inline-block;
      line-height: 30px;
    }
  }
  .contact-list {
    width: 90%;
    margin: 10px 5%;
  }
}
.head-title {
  display: flex;
  line-height: 22px;
  .info {
    line-height: 28px;
    border: 1px solid #333;
    margin-left: 20px;
    font-size: 12px;
    border-radius: 5px;
    padding: 0 8px;
  }
}
.head-title2 {
  display: flex;
  justify-content: space-between;
}
.bg1 {
  background:#98e48b;
}
</style>